<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('referrals', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->comment('the user that registered');
            $table->unsignedBigInteger('referred_by')->comment('the user that was referred');
            $table->integer('referral_earning')->default(0)->comment('update the amount when the user that registered buys a plan');
            $table->unsignedBigInteger('order_id')->nullable()->comment('update the order id when the user that registered buys a plan');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('referrals');
    }
};
